#include "Button.h"


Button::Button()
{
}


Button::~Button()
{
}

void Button::DrawButton(bool sel, std::string string, int tex_id)
{
	int px_start, py_start;
	int px_controls, py_controls;
	int px_scores, py_scores;
	int px_credits, py_credits;
	int px_back, py_back;

	px_start = 354;
	py_start = 300;
	px_controls = 325;
	py_controls = 250;
	px_scores = 340;
	py_scores = 200;
	px_credits = 337;
	py_credits = 150;
	px_back = 337;
	py_back = 100;

	if (string == "play.png")
	{	
		m_x0 = px_start;
		m_y0 = 608-py_start-41;
		m_x1 = px_start + 93;
		m_y1 = 608-py_start;

		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, tex_id);
		if (!sel){
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_start, py_start);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_start + 93, py_start);
			glTexCoord2f(1.0f, 0.0f); glVertex2f(px_start + 93, py_start + 41);
			glTexCoord2f(0.0f, 0.0f); glVertex2f(px_start, py_start + 41);
			glEnd();
		}
		else
		{
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex2f(px_start, py_start);
			glTexCoord2f(1.0f, 1.0f); glVertex2f(px_start + 93, py_start);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_start + 93, py_start + 41);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_start, py_start + 41);
			glEnd();
		}
		glDisable(GL_TEXTURE_2D);
	}

	if (string == "controls.png")
	{
		m_x0 = px_controls;
		m_y0 = 600-py_controls-41;
		m_x1 = px_controls + 151;
		m_y1 = 600-py_controls;

		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, tex_id);
		if (!sel){
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_controls, py_controls);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_controls + 151, py_controls);
			glTexCoord2f(1.0f, 0.0f); glVertex2f(px_controls + 151, py_controls + 41);
			glTexCoord2f(0.0f, 0.0f); glVertex2f(px_controls, py_controls + 41);
			glEnd();
		}
		else
		{
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex2f(px_controls, py_controls);
			glTexCoord2f(1.0f, 1.0f); glVertex2f(px_controls + 151, py_controls);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_controls + 151, py_controls + 41);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_controls, py_controls + 41);
			glEnd();
		}
		glDisable(GL_TEXTURE_2D);
	}

	if (string == "scores.png")
	{
		m_x0 = px_scores;
		m_y0 = 600-py_scores-41;
		m_x1 = px_scores + 120;
		m_y1 = 600-py_scores;

		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, tex_id);

		if (!sel){
			
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_scores, py_scores);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_scores + 120, py_scores);
			glTexCoord2f(1.0f, 0.0f); glVertex2f(px_scores + 120, py_scores + 41);
			glTexCoord2f(0.0f, 0.0f); glVertex2f(px_scores, py_scores + 41);
			glEnd();
		}
		else
		{
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex2f(px_scores, py_scores);
			glTexCoord2f(1.0f, 1.0f); glVertex2f(px_scores + 120, py_scores);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_scores + 120, py_scores + 41);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_scores, py_scores + 41);
			glEnd();
		}
		glDisable(GL_TEXTURE_2D);
	}

	if (string == "credits.png")
	{
		m_x0 = px_credits;
		m_y0 = 600-py_credits-41;
		m_x1 = px_credits + 126;
		m_y1 = 600-py_credits;

		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, tex_id);
		if (!sel){
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_credits, py_credits);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_credits + 126, py_credits);
			glTexCoord2f(1.0f, 0.0f); glVertex2f(px_credits + 126, py_credits + 41);
			glTexCoord2f(0.0f, 0.0f); glVertex2f(px_credits, py_credits + 41);
			glEnd();
		}
		else
		{
			glBegin(GL_QUADS);
			glTexCoord2f(0.0f, 1.0f); glVertex2f(px_credits, py_credits);
			glTexCoord2f(1.0f, 1.0f); glVertex2f(px_credits + 126, py_credits);
			glTexCoord2f(1.0f, 0.5f); glVertex2f(px_credits + 126, py_credits + 41);
			glTexCoord2f(0.0f, 0.5f); glVertex2f(px_credits, py_credits + 41);
			glEnd();
		}
		}
		glDisable(GL_TEXTURE_2D);

		if (string == "back.png")
		{
			m_x0 = px_back;
			m_y0 = 600 - py_back - 41;
			m_x1 = px_back + 96;
			m_y1 = 600 - py_back;

			glEnable(GL_TEXTURE_2D);
			glBindTexture(GL_TEXTURE_2D, tex_id);
			if (!sel){
				glBegin(GL_QUADS);
				glTexCoord2f(0.0f, 0.5f); glVertex2f(px_back, py_back);
				glTexCoord2f(1.0f, 0.5f); glVertex2f(px_back + 96, py_back);
				glTexCoord2f(1.0f, 0.0f); glVertex2f(px_back + 96, py_back + 41);
				glTexCoord2f(0.0f, 0.0f); glVertex2f(px_back, py_back + 41);
				glEnd();
			}
			else
			{
				glBegin(GL_QUADS);
				glTexCoord2f(0.0f, 1.0f); glVertex2f(px_back, py_back);
				glTexCoord2f(1.0f, 1.0f); glVertex2f(px_back + 96, py_back);
				glTexCoord2f(1.0f, 0.5f); glVertex2f(px_back + 96, py_back + 41);
				glTexCoord2f(0.0f, 0.5f); glVertex2f(px_back, py_back + 41);
				glEnd();
			}
		}
		glDisable(GL_TEXTURE_2D);
}




int Button::GetX0()
{
	return m_x0;
}

int Button::GetY0()
{
	return m_y0;
}

int Button::GetX1()
{
	return m_x1;
}

int Button::GetY1()
{
	return m_y1;
}
